$(document).ready(function(){
	$("#functionNav").attr("href",navAddr);

	$('.dateInput').datetimepicker({
		format: 'yyyy-mm-dd',
        forceParse: 0,
        todayBtn:  1,
        autoclose: 1,
        todayHighlight: 1,
        minView: 2,
        bootcssVer:3
    });

	cpfl1Json = ajaxResult("get",false,ProjectName+"/sysmanage.getIdNameByParentid.do", {"tableName":'jb_cplb', 'parentid':'0'});
	cpfl1Json = cpfl1Json.rows;
	loadSelect("#cpfl1",cpfl1Json,'id','name');

  	//获取并填充保管部门
	var bgbmJson = ajaxResult("get",false,ProjectName+"/sysmanage.getIdAndNameInjb.do",{'tableName':'jb_bgbm'});
	loadSelect("#form1 select[name=bgbm]",bgbmJson.rows,'id','name');
	
	//根据保管部门id获取并填充库房
	$('select[name=bgbm]').change(function(){
		var bgbmid = $(this).val();
		if(bgbmid !=null && bgbmid !=''){
			var kfJson = ajaxResult("get",false,ProjectName+"/sysmanage.getkfIdNameBybgbmId.do",{'bgbmId':bgbmid});
			loadSelect("select[name=szkf]",kfJson.rows,'kfid','kfmc');
		}
	});
	
	var params =$("#form1").serializeObject();
	createTable('#cqwhtbl',ProjectName+'/colmanage.getCqwhByStatus.do','id',tblColTitle1,params);	
	//点击查询按钮
	 $("#search_btn").click(function(){
		 $('#cqwhtbl').bootstrapTable('destroy');	
		 var params =$("#form1").serializeObject();
		 var status = $("#status").val();
		 if(status==0)
			 createTable('#cqwhtbl',ProjectName+'/colmanage.getCqwhByStatus.do','id',tblColTitle1,params);
		 else
			 createTable('#cqwhtbl',ProjectName+'/colmanage.getCqwhByStatus.do','id',tblColTitle2,params);
	 });
})

var tblColTitle1 = [{
	        field: 'zdjh',
	        title: '总登记号',
	        sortable:true
	    }, {
	        field: 'cpmc',
	        title: '藏品名称',
	        sortable:true
	    },  {
	        field: 'djbh',
	        title: '单据编号'
	    }, {
	        field: 'bt',
	        title: '利用任务名称'
	    }, {
	        field: 'cksj',
	        title: '出库时间'
	    }, {
	        field: 'yjtksj',
	        title: '预计退库时间'
	    }, {
	        field: 'ckdjr',
	        title: '出库点交人'
	    }, {
	        field: 'cktqr',
	        title: '出库提取人'
	    }, {
	        field: 'sqbmmc',
	        title: '申请部门'
	    }, {
	        field: 'sqrmc',
	        title: '申请人'
	    }]

var tblColTitle2 = [{
	        field: 'zdjh',
	        title: '总登记号',
	        sortable:true
	    }, {
	        field: 'cpmc',
	        title: '藏品名称',
	        sortable:true
	    }, {
	        field: 'djbh',
	        title: '单据编号'
	    }, {
	        field: 'bt',
	        title: '利用任务名称'
	    }, {
	        field: 'cksj',
	        title: '出库时间'
	    }, {
	        field: 'yjtksj',
	        title: '预计退库时间'
	    }, {
	        field: 'tksj',
	        title: '实际退库时间'
	    },{
	        field: 'ckdjr',
	        title: '出库点交人'
	    }, {
	        field: 'cktqr',
	        title: '出库提取人'
	    }, {
	        field: 'sqbmmc',
	        title: '申请部门'
	    }, {
	        field: 'sqrmc',
	        title: '申请人'
	    }]